import React, { Component } from 'react'
import './index.css'
export default class Item extends Component {
    render() {
        // 接收todo
        let {todo, deleteTodo,changeDone} = this.props
        return (
            <li>
                <label>
                    <input type="checkbox" checked={todo.isDone} onChange={(e)=>{
                        console.log(e.target.checked);// 最新的复选框选中状态也就是最新的isDone
                        changeDone(todo.id, e.target.checked);
                    }}/>
                    <span>{todo.title}</span>
                </label>
                <button className="btn btn-danger" onClick={()=>deleteTodo(todo.id)}>删除</button>
            </li>
        )
    }
}
